package com.ruleengine.instruction.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import com.ruleengine.instruction.InstructionType;

public class MulticastInstruction extends BaseInstruction {

    Map<String, ForkCase> cases = new HashMap<String, ForkCase>();

    public MulticastInstruction() {
        super(InstructionType.MULTICAST);
    }
    
    public void addForkCase( String caseId, int offset){
        cases.put(caseId, new ForkCase(caseId,offset));
    }
    
    public Iterator<ForkCase> iterator(){
        return cases.values().iterator();
    }
    
    public class ForkCase {
        String caseId;
        int offset;

        public ForkCase(String caseId, int offset) {
            this.caseId = caseId;
            this.offset = offset;
        }

        public String getCaseId() {
            return caseId;
        }

        public void setCaseId(String caseId) {
            this.caseId = caseId;
        }

        public int getOffset() {
            return offset;
        }

        public void setOffset(int offset) {
            this.offset = offset;
        }
        
        @Override
        public String toString() {
            return caseId + "," + offset;
        }
    }

    
    @Override
    public String toString() {
        return "{" + super.toString() + ",[" + cases + "]}";
    }

}
